from selenium.webdriver.common.by import By


class Judge:

    # 判断是否为中文摘要
    def Chinese(self, web):
        try:
            web.find_element(By.XPATH, '//*[@id="ChDivSummary"]')
            return True
        except:
            return False

    # 判断是否存在下一页
    def Next_page(self, web):
        try:
            web.find_element(By.XPATH, '//*[@id="PageNext"]')
            return True
        except:
            return False

    # 判断是否为英文摘要
    def English(self, web):
        try:
            web.find_element(By.XPATH, '//*[@id="doc-summary-content-text"]')
            return True
        except:
            return False

    # 判断是否打开了子网页
    def is_child_page(self, web):
        try:
            web.switch_to.window(web.window_handles[1])
            return True
        except:
            return False